//
//  VisitorBaseTableViewController.swift
//  微博
//
//  Created by 段瑞金 on 16/5/11.
//  Copyright © 2016年 段瑞金. All rights reserved.
//

import UIKit

class VisitorBaseTableViewController: UITableViewController {

    //是否登录的属性
    var userLogin : Bool = UserAccountItem.userLogin()
    //保存访客视图
    var visitorView : VisitorView!
    
 
    override func loadView() {
        if userLogin {
            super.loadView()
        }else{
            visitorView = VisitorView()
            visitorView.leftRegisterBtn.addTarget(self, action: #selector(VisitorBaseTableViewController.registerButtonOnClick), forControlEvents: .TouchUpInside)
            visitorView.rightLoginBtn.addTarget(self, action: #selector(VisitorBaseTableViewController.loginButtonOnClick), forControlEvents: .TouchUpInside)
            view = visitorView
        }
    }

    
    override func viewDidLoad() {
        super.viewDidLoad()
        //初始化导航条

        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: #selector(VisitorBaseTableViewController.registerButtonOnClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: #selector(VisitorBaseTableViewController.loginButtonOnClick))
        
    }
    
    //MARK:-按钮监听点击
    
    @objc private func registerButtonOnClick () -> (){
        RJLOG("")
    }

    
    @objc private func loginButtonOnClick () -> (){
//        RJLOG("")
        //创建
        let authorViewController = AuthorViewController()
        //包装一个导航控制器
        let nav = UINavigationController(rootViewController: authorViewController)
        //弹出
        presentViewController(nav, animated: true, completion: nil)
    }


}
